function setLocalizedTemplates(type){
	
	$.mobile.loading('show');
	
	var locale = window.localStorage.getItem("locale");
	
	if(locale && locale!=""){
		loadLocalizedFile(type + "_" + locale + ".json");
	} else{
		navigator.globalization.getLocaleName(
			function (locale) {
				  //alert('locale: ' + locale.value + '\n');
				  var arrLocale = locale.value.split("_");
				  loadLocalizedFile(type + "_" + arrLocale[0] + ".json");
			},
			function () {
				alert('Error getting locale. Using default: en');
				loadLocalizedFile(type + "_en.json");
			}
		);
	}
}


function loadLocalizedFile(fileName){
	
	//alert("decisionTemplates/" + fileName);
	
	$.ajax({
    	url:"decisionTemplates/" + fileName,
    	dataType:'JSON',
    	'global': false,
    	'async': false,
    	success: function(data){
    		//alert(data);
	    	$.each(data, function(key, val) {
	    		//alert("key:" + key + ", val: " + val);
	    		preloadedCriterias.push(val);
    		});
	    	
	    	var interval = setInterval(function(){
    	        $.mobile.loading('hide');
    	        clearInterval(interval);
    	        //$("#step_1").fadeIn("fast", function(){
        	        setCriterias();
    	        //});
	    	},1);
	    },
	    error: function (xhr, ajaxOptions, thrownError) {
	        alert(xhr.status);
	        alert(thrownError);
	    }
	});  
}